// pages/sao/sao.js
const app = getApp()
const Host = require('../../config').Host
Page({

  /**
   * 页面的初始数据
   */
  data: {
    textTip:"扫码成功"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    that.setData({
      encryptstr: options.encryptstr,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that=this;
    var openid = wx.getStorageSync('openid');
    var encryptstr = that.data.encryptstr;
    wx.request({
      url: Host + 'Mine/stringService1',
      data: { openid, encryptstr},
      method: 'post',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        if (res.data.code == 200) {
          that.setData({
            textTip: '扫码成功',
          })
          setTimeout(function () {
            wx.switchTab({
              url: '/pages/personal/personal',
            })
          }, 2000)
        } else {
          that.setData({
            textTip: res.data.errmsg,
          })
        }
      },
    })

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})